<template>
  <div class="">
    <heads></heads>
    <main>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-form label-position="left" inline class="demo-table-expand">
              <el-form-item label="用户名">
                <span>{{ props.row.userList.username }}</span>
              </el-form-item>
              <el-form-item label="店铺名称">
                <span>{{ props.row.busList.businessName }}</span>
              </el-form-item>
              <el-form-item label="收货地址">
                <span>{{ props.row.userList.address }}</span>
              </el-form-item>
              <el-form-item label="店铺ID">
                <span>{{ props.row.busList.id }}</span>
              </el-form-item>
              <el-form-item label="店铺地址">
                <span>{{ props.row.busList.businessAddress }}</span>
              </el-form-item>
            </el-form>
          </template>
        </el-table-column>
        <el-table-column label="订单ID" prop="id"> </el-table-column>
        <el-table-column label="总价格" prop="sumMoney"> </el-table-column>
        <el-table-column label="订单状态">
          <template slot-scope="scope">
            {{ scope.row.orderStatus ? "成功交易" : "支付超时" }}
          </template></el-table-column
        >
      </el-table>
    </main>
    <footer>
      <el-pagination background layout="prev, pager, next" :total="pageSum * 10" v-on:prev-click="perventPage" v-on:next-click="nextPage" v-on:current-change="changePage"> </el-pagination>
    </footer>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';
import heads from "@/components/adminHead.vue";

import { selectOrders } from "@/api/getPostApi";

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {
    heads,
  },
  data() {
    //这里存放数据
    return {
      tableData: [],
      page: 1,
      pageSum: 0,
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    selectOrderList() {
      selectOrders(this.page).then((response) => {
        this.tableData = response.data.orderList;
        this.pageSum = Math.ceil(response.data.count / 10);
      });
    },
    perventPage() {
      this.page -= 1;
      this.selectOrderList();
    },

    nextPage() {
      this.page += 1;
      this.selectOrderList();
    },

    changePage(val) {
      this.page = val;
      this.selectOrderList();
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {
    this.selectOrderList();
  },
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="scss" scoped>
//@import url(); 引入公共css类
@import "@/style/mixin.scss";
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  @include marginWidth;
}

footer {
  @include footer;
}
</style>
